﻿namespace WMS6.Web
{
    using System;
    using System.Collections.Generic;
    using System.Web;
    using WMS6.Web.TransportMgtDetailServiceRef;

    public class TransportDetailMgtServiceClientProxy : BasePage
    {
        public string DeleteDeliveryOrderDetailInfo(List<string> deliveryOrderIDs, List<string> lineIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.DeleteDeliveryOrderDetailInfo(deliveryOrderIDs, lineIDs, pubParasInfo);
            }
        }

        public string DeleteDispatchDetailInfo(List<string> dispatchDetailInfoIDs, List<string> lineIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.DeleteDispatchDetailInfo(dispatchDetailInfoIDs, lineIDs, pubParasInfo);
            }
        }

        public string DeletePodDetailInfo(List<string> podIDs, List<string> lineIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.DeletePodDetailInfo(podIDs, lineIDs, pubParasInfo);
            }
        }

        public List<DeliveryOrderAndDispatchDataInfo> GetDeliveryOrderAndDispatchDataInfoByIDs(List<string> dispatchDetailInfoIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.GetDeliveryOrderAndDispatchDataInfoListByIDs(dispatchDetailInfoIDs, pubParasInfo);
            }
        }

        public DeliveryOrderDetailInfo GetDeliveryOrderDetailInfoBypoIDAndLineID(string deliveryOrderID, string lineID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.GetDeliveryOrderDetailInfoByID(deliveryOrderID, lineID, pubParasInfo);
            }
        }

        public List<DeliveryOrderDetailInfo> GetDeliveryOrderDetailInfoListByIDs(string deliveryOrderID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.GetDeliveryOrderDetailInfoListByID(deliveryOrderID, pubParasInfo);
            }
        }

        public DispatchDetailInfo GetDispatchDetailInfoByIDAndLineID(string dispatchDetailInfoID, string lineID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.GetDispatchDetailInfoByID(dispatchDetailInfoID, lineID, pubParasInfo);
            }
        }

        public List<DispatchDetailInfo> GetDispatchDetailInfoListByID(string dispatchDetailInfoID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.GetDispatchDetailInfoListByID(dispatchDetailInfoID, pubParasInfo);
            }
        }

        public static TransportDetailMgtServiceClientProxy GetInstance()
        {
            return new TransportDetailMgtServiceClientProxy();
        }

        public PodDetailInfo GetPodDetailInfoByID(string podID, string lineID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.GetPodDetailInfoByID(podID, lineID, pubParasInfo);
            }
        }

        public List<PodDetailInfo> GetPodDetailInfoListByID(string podIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.GetPodDetailInfoListByID(podIDs, pubParasInfo);
            }
        }

        private PubParasInfo InitPubParasInfo()
        {
            if (base.UserInfo != null)
            {
                return new PubParasInfo { UserID = base.UserInfo.UserID, UserLanguage = base.UserInfo.Preference.Lang, CurrentWH = base.UserInfo.CurrentWH };
            }
            HttpContext.Current.Response.Redirect("../Login.aspx?from=Logout", true);
            return null;
        }

        public string InsertDeliveryOrderDetailInfo(DeliveryOrderDetailInfo deliveryOrderDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.InsertDeliveryOrderDetailInfo(deliveryOrderDetailInfo, pubParasInfo);
            }
        }

        public string InsertDispatchDetailInfo(DispatchDetailInfo dispatchDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.InsertDispatchDetailInfo(dispatchDetailInfo, pubParasInfo);
            }
        }

        public string InsertPodDetailInfo(PodDetailInfo podDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.InsertPodDetailInfo(podDetailInfo, pubParasInfo);
            }
        }

        public string UpdateDeliveryOrderDetailInfo(DeliveryOrderDetailInfo deliveryOrderDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.UpdateDeliveryOrderDetailInfo(deliveryOrderDetailInfo, pubParasInfo);
            }
        }

        public string UpdateDispatchDetailInfo(DispatchDetailInfo dispatchDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.UpdateDispatchDetailInfo(dispatchDetailInfo, pubParasInfo);
            }
        }

        public string UpdatePodDetailInfo(PodDetailInfo podDetailInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (TransportMgtDetailServiceClient client = new TransportMgtDetailServiceClient("WSHttpBinding_ITransportMgtDetailService"))
            {
                return client.UpdatePodDetailInfo(podDetailInfo, pubParasInfo);
            }
        }
    }
}

